package com.lysky.selfllm.controller.config;


import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import dev.langchain4j.store.memory.chat.redis.RedisChatMemoryStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ChatMemoryConfig {

    @Bean
    public ChatMemory chatMemory(){
        ChatMemoryStore chatMemoryStore = RedisChatMemoryStore.builder()
                .host("localhost")
                .port(6379)
                .build();
        return MessageWindowChatMemory.builder()
                .maxMessages(100)
                .chatMemoryStore(chatMemoryStore)
                .build();
    }
}
